﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Net;

namespace Bonobo.Irc.Client.UI.Data
{
    // FIXME: won't be needed, as we are going to use hostnames (WOW, 1980s technology! :))
    //        if we were to keep it, it should be in Data namespace and internal sealed

    //        BTW, shouldn't the methods be reversed? ie. Convert converting String to IPAddress?
    [ValueConversion(typeof(object), typeof(IPAddress))]
    public class IPAddressConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return (value ?? String.Empty).ToString();
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            return IPAddress.Parse((value ?? String.Empty).ToString());
        }
    }
}
